﻿#pragma once
/**
@author 何炜
@date 2011/5/16
@brief .
@details
*/

namespace GLL
{	
	template<typename T>
	class Size2D
	{
	public:
		union{T width; T x;};
		union{T height; T y;};
		Size2D(){width = height = 0;}
		Size2D(T v){width = height = v;}
		Size2D(T w, T h){width = w; height = h;}
		static const Size2D& ZERO()
		{
			static Size2D<T> zero;
			return zero;
		}
	};

	typedef Size2D<int> Size2Di;
	typedef Size2D<float> Size2Df;

	template<typename T>
	class Position2D
	{
	public:
		union{T left; T x;};
		union{T top; T y;};
		Position2D(){left = top = 0;}
		Position2D(T v){left = top = v;}
		Position2D(T l, T t){left = l; top = t;}
		static const Position2D& ZERO()
		{
			static Position2D<T> zero;
			return zero;
		}
	};

	typedef Position2D<int> Position2Di;
	typedef Position2D<float> Position2Df;
	typedef Position2D<float> Axis2Df;

	template<typename T>
	class Position3D
	{
	public:
		T x;
		T y;
		T z;
		Position3D(){x = y = z = 0;}
		Position3D(T v){x = y = z = v;}
		Position3D(T ax, T ay, T az){x = ax; y = ay; z = az;}
		T X() const{return (T)x;}
		T Y() const{return (T)y;}
		T Z() const{return (T)z;}
		void SetX(T v){ x = v;}
		void SetY(T v){ y = v;}
		void SetZ(T v){ z = v;}
		static const Position3D& ZERO()
		{
			static Position3D<T> zero;
			return zero;
		}
	};

	typedef Position3D<int> Position3Di;
	typedef Position3D<float> Position3Df;
	typedef Position3D<float> Axis3Df;

	template<typename T>
	class Size3D
	{
	public:
		union{T width; T x;};
		union{T height; T y;};
		union{T deepth; T z;};
		Size3D(){width = height = deepth = 0;}
		Size3D(T v){width = height = deepth = v;}
		Size3D(T w, T h, T d){width = w; height = h; deepth = d;}
		T Width() const{return (T)width;}
		T Height() const{return (T)height;}
		T Deepth() const{return (T)deepth;}
		void SetWidth(T w){width = w;}
		void SetHeight(T h){height = h;}
		void SetDeepth(T d){deepth = d;}
		static const Size3D& ZERO()
		{
			static Size3D<T> zero;
			return zero;
		}
	};

	typedef Size3D<int> Size3Di;
	typedef Size3D<float> Size3Df;

	template<typename T>
	class Area2D : public Position2D<T>, public Size2D<T>
	{
	public:
		Area2D(T v):Position2D(v), Size2D(v){}
		Area2D(T lft, T tp, T wdth, T hght):Position2D(lft, tp), Size2D(wdth, hght){}
		T Right() const {return left + width;}
		T Bottom() const {return top + height;}
		void SetRight(T v) const {width = v - left;}
		void SetBottom(T v) const {height = v - top;}
		static const Area2D& ZERO()
		{
			static Area2D<T> zero;
			return zero;
		}
	};

	typedef Area2D<int> Area2Di;
	typedef Area2D<float> Area2Df;
};//GLL
